package builder;

public class StringBuilderTest {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
    String sum = "[";
    for (int  i = 0; i < arr.length ; i++){
        if (i== arr.length-1){
            sum += (arr[i] + "]");
        }else {
            sum+=(arr[i] + ",");
        }
    }
        System.out.println("sum = " + sum);

    StringBuilder sbSum = new StringBuilder("[");
        for (int i = 0; i < arr.length; i++) {
            if (i==arr.length-1){
                sbSum.append(arr[i]).append("]");
            }else {
                sbSum.append(arr[i]).append(",");
            }
        }
        System.out.println("sbSum = " + sbSum);

    }

}
